//
//  HBEdgeInsetsLabel.m
//  HBLibary
//
//  Created by Rambo on 2018/11/4.
//

#import "HBEdgeInsetsLabel.h"

@implementation HBEdgeInsetsLabel

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
    UIEdgeInsets insets = self.edgeInsets;
    CGRect rect = [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)
                    limitedToNumberOfLines:numberOfLines];
    
    rect.origin.x    -= insets.left;
    rect.origin.y    -= insets.top;
    rect.size.width  += (insets.left + insets.right);
    rect.size.height += (insets.top + insets.bottom);
    
    return rect;
}

- (void)drawTextInRect:(CGRect)rect {
    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.edgeInsets)];
}

//- (CGSize)sizeThatFits:(CGSize)size{
//    CGSize oriSize = [super sizeThatFits:size];
////    oriSize.width += self.edgeInsets.left + self.edgeInsets.right;
////    oriSize.height += self.edgeInsets.top + self.edgeInsets.bottom;
//    return oriSize;
//}


@end
